package com.naivesoft.lottery;

import java.util.List;

import com.naivesoft.lottery.util.CustomDialog;
import com.naivesoft.lottery.widget.BallPannel;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AnalogClock;
import android.widget.Toast;

public class GuessLotteryActivity extends Activity {
	
	private CustomDialog customDialog;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        AnalogClock analogClock = (AnalogClock) findViewById(R.id.clock);
        analogClock.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				customDialog = new CustomDialog(GuessLotteryActivity.this);
				customDialog.setCancelButton(null);
				customDialog.setOkButton(new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						Toast.makeText(GuessLotteryActivity.this, "click ok", Toast.LENGTH_SHORT).show();
						customDialog.cancel();
					}
				});
				customDialog.setCancelable(true);
				customDialog.show();
			}
		});
        
        final BallPannel ballPannel = (BallPannel) findViewById(R.id.ball_pannel);
        ballPannel.setOnCheckedBallChangeListener(new BallPannel.OnCheckedBallChangeListener() {
			
			@Override
			public void onCheckedBallChange(List<Integer> redBalls,
					List<Integer> blueBalls) {
			}
		});
        ballPannel.setOnFinishChooseBallsListener(new BallPannel.OnFinishChooseBallsListener() {
			
			@Override
			public void onFinishChooseBalls(List<Integer> redBalls,
					List<Integer> blueBalls) {
				customDialog = new CustomDialog(GuessLotteryActivity.this);
				customDialog.setContent("Red Balls: " + redBalls.toString()
						+ "\nBlue Balls: " + blueBalls.toString());
				customDialog.setCancelButton(null);
				customDialog.setOkButton(new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						Toast.makeText(GuessLotteryActivity.this, "click ok", Toast.LENGTH_SHORT).show();
						customDialog.cancel();
					}
				});
				customDialog.setCancelable(true);
				customDialog.show();
				ballPannel.clearAllBalls();
			}
		});
    }
}